home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / gettext.arc / GETTEXT.C next >
C/C++ Source or Header  |  1988-07-05  |  4KB  |  154 lines

  1. #include "d:\include\osbind.mjh"
  2.  
  3. main(argc,argv)
  4.   int argc;
  5.   char *argv[];
  6.   { int i,j,k,e,cnt,ch,ccnt,flug,flag,head,tail,count,flog,buffcnt,handle,p,
  7.     int flow;
  8.     char c,d;
  9.     static char filename[] = {""};
  10.     static char buffer[8192];
  11.     char incmd[6];
  12.     char outcmd[7];
  13.     char runcmd[4];
  14.  
  15.     incmd[0]='i'; incmd[1]='n'; incmd[2]='c'; incmd[3]='a'; incmd[4]='t';
  16.     incmd[5]='\0'; 
  17.     outcmd[0]='o'; outcmd[1]='u'; outcmd[2]='t'; outcmd[3]='c'; outcmd[4]='a';
  18.     outcmd[5]='t'; outcmd[6]='\0';
  19.     runcmd[0]='c'; runcmd[1]='a'; runcmd[2]='t'; runcmd[3]='\0';
  20.  
  21.     if (argc != 2)
  22.     { printf("\nuseage: gettext [%%][+]<filename>\n\n");
  23.       goto alpha;
  24.     }
  25.  
  26.     flug = 0;
  27.     flag = 0;
  28.     flog = 0;
  29.     k = 0;
  30.     e = 1;
  31.     flow = 0;
  32.     Rsconf(-1,e,-1,-1,-1,-1);
  33.     Vsync(); Vsync(); Vsync(); Vsync();
  34.  
  35.     while (Bconstat(1) != 0) Bconin(1);
  36.     while (Bconstat(2) != 0) Bconin(2);
  37.  
  38.     buffcnt = 0;
  39.     while (incmd[buffcnt] != '\0') { Bconout(1,(int)incmd[buffcnt++]); }
  40.     Bconout(1,(int)'\r');
  41.  
  42.     d = ' ';
  43.     while (d != 'y')
  44.     { if (Bconstat(1) != 0) d = Bconin(1) & 0x7F;
  45.       if (Bconstat(2) != 0) 
  46.       { while (Bconstat(2) != 0) d = Bconin(2) & 0x7F;
  47.         goto gamma;
  48.       }
  49.     }
  50.  
  51. /*  printf("\nGetting file...");  */
  52.  
  53.     buffcnt = 0;
  54.     while (runcmd[buffcnt] != '\0') { Bconout(1,(int)runcmd[buffcnt++]); }
  55.     Bconout(1,(int)' ');
  56.  
  57.     if (*argv[1] == '%') { flag = 1; argv[1]++;}
  58.     if (*argv[1] == '+') { flog = 1; argv[1]++;}
  59.  
  60.     k = 0;
  61.     while (filename[k] != '\0') {k++;}
  62.     count = k;
  63.     while (*argv[1] >= '!')
  64.       { Bconout(1,(int)*argv[1]);
  65. /*    printf("%c",*argv[1]); */
  66.         if (*argv[1] != '/')
  67.         { filename[count++] = *argv[1]; }
  68.         else
  69.         { count = k; }
  70.         argv[1]++;
  71.       }
  72.     argv[1]++;
  73.     filename[count++] = '\0';
  74.  
  75.     Bconout(1,(int)'\r');
  76. /*  printf("\n\n");  */
  77.  
  78.     i = 0;
  79.     j = 0;
  80.     head = 0;
  81.     tail = 0;
  82.     d = '\0';
  83.  
  84.     while (d < '\40')
  85.     { if (Bconstat(1) != 0) 
  86.       { d = Bconin(1) & 0x7F; }
  87.       if (Bconstat(2) != 0) 
  88.       { while (Bconstat(2) != 0) d = Bconin(2) & 0x7F;
  89.         goto alpha;
  90.       }
  91.     }
  92.  
  93.     ch = 0;
  94.     while (k <= 5000) 
  95.     { if ((Bconstat(1) != 0) && (flow == 0))
  96.       {  if (ch != 0) 
  97.          { d = Bconin(1) & 0x7F; }
  98.          ch = 1;
  99.          cnt = 1;
  100.          if (d == '\9')
  101.          { cnt = 8; d = ' '; }
  102.          for (ccnt=1 ; ccnt<=cnt ; ccnt++)
  103.          { buffer[tail++] = d;
  104.            if (tail >= 8190) { tail = 0; }
  105.            if (((tail - head) == 3072) || ((head - tail) == 1024))
  106.            { Bconout(1,(int)'\23'); 
  107.              flow = 1; 
  108.            }
  109.          }
  110.       }
  111.       if (head != tail)
  112.       {  j = 0;
  113.          if (flog == 0)
  114.          { while ((Bcostat(0) == 0) && (j < 100)) {j++;}
  115.            if (j < 100) 
  116.            { Bconout(0,(int)buffer[head]);
  117.              k=0; 
  118.            }
  119.          }
  120.          if (j < 100) 
  121.          { if (((i++ < 120) || (flag == 1) || (flog == 1)) &&
  122.                (buffer[head] != '\015'))
  123.            { printf("%c",buffer[head]); }
  124.            head++;
  125.            if (head >= 8190) { head = 0; }
  126.            if (((tail - head) == 1024) || ((head - tail) == 3072))
  127.            { Bconout(1,(int)'\21');
  128.              flow = 0;
  129.            }
  130.            k = 0;
  131.          }
  132.       }
  133.       if (Bconstat(2) != 0)
  134.       {  d = Bconin(2); goto beta; }
  135.       k++;
  136.     }
  137.  
  138. beta: if (flog == 0)
  139.       { Bconout(0,(int)'\13');
  140.         Bconout(0,(int)'\13');
  141.         Bconout(0,(int)'\15');
  142.       }
  143.       Bconout(1,(int)'\3'); 
  144.       printf("\n");  
  145.  
  146. gamma:
  147.       buffcnt = 0;
  148.       while (outcmd[buffcnt] != '\0') { Bconout(1,(int)outcmd[buffcnt++]); }
  149.       Bconout(1,(int)'\r');
  150.  
  151. alpha:
  152.       Pterm(0);
  153.   }
  154.